Python and LXML: changing an attribute only in specific contexts